package com.zany.system.service;

import java.util.List;

import com.zany.system.dao.PasswordInfoDao;
import com.zany.system.dao.UserInfoDao;
import com.zany.system.vo.UserInfoVO;
import com.zany.util.action.MD5;



public class UserInfoServiceImpl implements UserInfoService{

	private PasswordInfoDao passwordInfoDao;
	private UserInfoDao userInfoDao;
	/**
	 * 查询该用户ID是否使用
	 * @param userInfoVO
	 * @return
	 */
	public Integer getUserInfo(UserInfoVO userInfoVO) {
		// TODO Auto-generated method stub
		return userInfoDao.getUserInfo(userInfoVO);
	}
	/**
	 * 分页查询用户基本信息
	 * @param userInfoVO
	 * @return
	 */
	public List<UserInfoVO> getAllUserInfoPage(UserInfoVO userInfoVO) {
		// TODO Auto-generated method stub
		return userInfoDao.getAllUserInfoPage(userInfoVO);
	}
	/**
	 * 查询用户总数
	 * @param userInfoVO
	 * @return
	 */
	public Integer getAllUserInfoCount(UserInfoVO userInfoVO) {
		// TODO Auto-generated method stub
		return userInfoDao.getAllUserInfoCount(userInfoVO);
	}
	/**
	 * 修改用户基本信息
	 * @param userInfoVO
	 */
	public void updateUserInfo(UserInfoVO userInfoVO) {
		// TODO Auto-generated method stub
		userInfoDao.updateUserInfo(userInfoVO);
	}
	/**
	 * 新增用户
	 * @param userInfoVO
	 */
	public void insertUserInfo(UserInfoVO userInfoVO) {
		// TODO Auto-generated method stub
		userInfoDao.insertUserInfo(userInfoVO);
	}
	public UserInfoDao getUserInfoDao() {
		return userInfoDao;
	}
	public void setUserInfoDao(UserInfoDao userInfoDao) {
		this.userInfoDao = userInfoDao;
	}
	/**
	 * 获取用户密码
	 * @param userInfoVO
	 * @return
	 */
	public UserInfoVO getPasswordInfo(UserInfoVO userInfoVO) {
		// TODO Auto-generated method stub
		return userInfoDao.getPasswordInfo(userInfoVO);
	}
	/**
	 * 修改密码
	 * @param userInfoVO
	 */
	public void updatePasswordInfo(UserInfoVO userInfoVO) {
		// TODO Auto-generated method stub
		userInfoDao.updatePasswordInfo(userInfoVO);
	}
	/**
	 * 查询用户角色总数
	 * @param userInfoVO
	 * @return
	 */
	public Integer getUserRoleInfoCount() {
		// TODO Auto-generated method stub
		return userInfoDao.getUserRoleInfoCount();
	}
	/**
	 * 分页查询用户角色
	 * @param userInfoVO
	 * @return
	 */
	public List<UserInfoVO> getUserRoleInfoPage(UserInfoVO userInfoVO) {
		// TODO Auto-generated method stub
		return userInfoDao.getUserRoleInfoPage(userInfoVO);
	}
	/**
	 * 查询角色列表
	 * @return
	 */
	public List<UserInfoVO> getRoleList(UserInfoVO userInfoVO) {
		// TODO Auto-generated method stub
		return userInfoDao.getRoleList(userInfoVO);
	}
	/**
	 * 分配角色
	 * @param userInfoVO
	 */
	public void setUserRole(UserInfoVO userInfoVO) {
		// TODO Auto-generated method stub
		userInfoDao.setUserRole(userInfoVO);
	}
	/**
	 * 分配机构
	 * @param userInfoVO
	 */
	public void setUserOrg(UserInfoVO userInfoVO) {
		// TODO Auto-generated method stub
		userInfoDao.setUserOrg(userInfoVO);
	}
	public Integer getAllRoleListCount() {
		// TODO Auto-generated method stub
		return this.userInfoDao.getAllRoleListCount();
	}
	public UserInfoVO getUserInfoDetail(UserInfoVO vo) {
		// TODO Auto-generated method stub
		return this.userInfoDao.getUserInfoDetail(vo);
	}
	public UserInfoVO getUserInfoDetailTemp(UserInfoVO vo) {
		// TODO Auto-generated method stub
		return this.userInfoDao.getUserInfoDetailTemp(vo);
	}
	public void updatePassword(String[] userCode) {
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		com.zany.system.vo.UserInfoVO userInfoVO = new UserInfoVO();
		if(userCode.length>0){
			for(int t=0;t<userCode.length;t++){
				userInfoVO.setUserCode(userCode[t]);
				userInfoVO.setPassword(MD5.md5("999999"));
				passwordInfoDao.updatePassword(userInfoVO);
			}
		}
	}
	public PasswordInfoDao getPasswordInfoDao() {
		return passwordInfoDao;
	}
	public void setPasswordInfoDao(PasswordInfoDao passwordInfoDao) {
		this.passwordInfoDao = passwordInfoDao;
	}
}
